//////////////////////////////////////////////////////////////////////////
//
// GAM203
// Timer
// Timer.cpp
// 
// Grant Johnson
// Qantm College
// 27/10/2010
//
//////////////////////////////////////////////////////////////////////////

#include "Timer.h"

Timer::Timer()
{
	QueryPerformanceFrequency(&m_freq);
	Reset();
	m_curTime = 0.0f;
	m_prevTime = 0.0f;
	m_deltaTime = 0.0f;
}

void Timer::Reset()
{
	QueryPerformanceCounter(&m_baseTime);
}

float Timer::GetTime()
{
	LARGE_INTEGER curTime;
	QueryPerformanceCounter(&curTime);

	return (float)(curTime.QuadPart - m_baseTime.QuadPart) / (float)m_freq.QuadPart;
}
float Timer::GetFrameTime()
{
	m_curTime = GetTime();
	m_deltaTime = m_curTime - m_prevTime;
	m_prevTime = m_curTime;
	return m_deltaTime;
}